package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsCategoryMapper;
import com.qf.pojo.DtsCategory;
import com.qf.service.DtsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZhangYuJie
 * projectName:shop_manage
 * time:2022/5/17 21:22
 * description:
 */
@Service
public class DtsCategoryServiceImpl implements DtsCategoryService {
    @Autowired
    private DtsCategoryMapper categoryMapper;

    @Override
    public List<DtsCategory> queryL1() {
        //设置查询条件
        QueryWrapper<DtsCategory> wapper = new QueryWrapper<>();
        wapper.eq("level", "L1");
        wapper.eq("deleted", false);
        return categoryMapper.selectList(wapper);
    }

    @Override
    public List<DtsCategory> queryByPid(Integer pid) {
        //设置查询条件
        QueryWrapper<DtsCategory> wapper = new QueryWrapper<>();
        wapper.eq("pid", pid);
        wapper.eq("deleted", false);
        return categoryMapper.selectList(wapper);
    }

    @Override
    public DtsCategory findById(Integer id) {
        return categoryMapper.selectById(id);
    }
}
